#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main(int argc, char const *argv[]) {
    ll t, n;
    cin >> t;
    while(t--) {
        cin >> n;
        int countN = 0;
        for(ll i = sqrt(n) + 10; n > 1 && i >= 1; i--) {
            ll temp = (3 * i * i + i) / 2;
            if (temp <= n) {
                n -= temp;
                countN++;
                i++;
            }
        }
        cout << countN << endl;
    }
    return 0;
}

// a_n = (3 * n * n + n) / 2
